import React from "react";
import { useLocation, useNavigate } from "react-router-dom";

const routes = ["/sel", "/pra"];

export default function BackButton() {
  const { pathname } = useLocation();
  let nav = useNavigate();
  return (
    <div
      className="back"
      onClick={() => nav(-1)}
      style={{
        position: "fixed",
        bottom: 0,
        left: 0,
        width: "100%",
        height: "160px",
        backgroundColor: "blue",
        display: routes.some((item) => pathname.indexOf(item) !== -1)
          ? "block"
          : "none",
      }}
    >
      返回上一页
    </div>
  );
}
